home *** CD-ROM | disk | FTP | other *** search
- include qlib.inc
-
- .code
-
- ;FIX! : v2.02 : these funcs were totaly fixed (they didn't work at all before)
-
- ;calls your PMODE function when seg:off (which is returned from here)
- ; is run by something (just set a RM int to what is returned)
- ; note: your proc must end with 'retf'
- ;out:
- ; ax:dx = RM seg:off to call
- callback_alloc proc,off:dword,calls:dword,typ:byte
- ;typ: 0=retf 1-iret (this is ignored by PMODE/W)
- ;off = your procedure
- pushad
- mov ax,303h
- mov esi,off ;your PROC
- mov edi,calls ;callstruct you must provide
- int 31h
- .if carry?
- popad
- mov eax,ERROR
- .else
- movzx ecx,cx
- movzx edx,dx
- mov [esp+7*4],ecx ;eax
- mov [esp+5*4],edx ;edx
- popad
- .endif
- ret
- callback_alloc endp
-
- callback_free proc,a:word,d:word ;a:d = ax:dx that was returned from alloc_realmode
- pushad
- mov ax,304h
- mov cx,a
- mov dx,d
- int 31h
- popad
- .if carry?
- mov eax,ERROR
- .else
- xor eax,eax
- .endif
- ret
- callback_free endp
-
- ; call this at the end of your PROC that was called by a callback
- ; this function does not return!
- ; don't worry about stack clean up or anything just call this and that's it
- ;use this one if the RMODE CS:IP was called FAR
- _retf proc,calls:dword ;calls= callstruct
- mov edi,calls
- xor eax,eax
- mov ax,es:[edi].callstruct._ss
- shl eax,4
- xor ebx,ebx
- add bx,es:[edi].callstruct._sp
- add eax,ebx
- mov bx,[eax]
- mov es:[edi].callstruct._ip,bx
- mov bx,[eax+2]
- mov es:[edi].callstruct._cs,bx
- add es:[edi].callstruct._sp,4
- iretd
- _retf endp
-
- ; call this at the end of your PROC that was called by a callback
- ; this function does not return!
- ; don't worry about stack clean up or anything just call this and that's it
- ;use this one if the RMODE CS:IP was called as an INT handler
- _iret proc,calls:dword
- mov edi,calls
- xor eax,eax
- mov ax,es:[edi].callstruct._ss
- shl eax,4
- xor ebx,ebx
- add bx,es:[edi].callstruct._sp
- add eax,ebx
- mov bx,[eax]
- mov es:[edi].callstruct._ip,bx
- mov bx,[eax+2]
- mov es:[edi].callstruct._cs,bx
- mov bx,[eax+4]
- mov es:[edi].callstruct._flg,bx
- add es:[edi].callstruct._sp,6
- iretd
- _iret endp
-
- end
-
-